program demo;

uses
  SysUtils, uTyp, uVar, uEng, uSpr, uInp, uFnt, uDrw, uSnd;

type
  TEng = class(uEng.TEng)
    procedure OnInit; override;
    procedure OnFrame; override;
    procedure OnStep; override;
  end;

var
  spr: TSpr;
  fnt: TFnt;
  s: TSnd;

procedure TEng.OnInit;
begin
  spr := TSpr.Create;
  spr.tex := res.AddTex('tex', 'data/tex.tga', True);
  fnt := res.AddFnt('fnt', 'data/fnt.tga', True);
  //fnt := res.AddFnt('fnt', 'fnt', 38, 300, 'Calibri', 512, 512, True);
  //fnt.Save('data/fnt.tga');
  //spr.tex := fnt.tex;
  s := snd.Add('s', 'data/s.ogg', True, False, -1);
end;

procedure TEng.OnFrame;
begin
  spr.Draw;
  fnt.Draw('Hello, World!', 200, 200, MakeClr($FFFFFF00));
  fnt.Draw('Snd bufs: ' + IntToStr(s.factSize), 10, 10, MakeClr($FFFFFFFF));
  drw.Circle(200, 200, 100, 100, MakeClr($99FFFFFF), DRW_FILL);
end;

procedure TEng.OnStep;
begin
  if inp.KeyDowned(KEY_ESCAPE) then eng.Stop;
  if inp.KeyPressed(KEY_P) then s.FindBuf.Play;

  eng.Update;
end;

begin
  eng := TEng.Create;
  //eng.conf.renderer := ENG_D3D8;
  //eng.conf.player := ENG_DS;

  if eng.Init then
    eng.Start;

  eng.Free;
end.
